# Note: Makefile only compatible with gnu-make
# To compile:
# make          // will compile optimised version
# make dbg=y    // will compile debug version

# Basic flags
CC := g++
CFLAGS := -Wall
LDFLAGS := 
OPTFLAGS := -O2
DBGFLAGS := -g -DDEBUG
EDGEFLAGS := -DSHOWEDGES
RM := rm

# Executable
EXE := ass2

# Files
SOURCES := main.cpp graph.cpp list.cpp utils.cpp set.cpp queue.cpp unordered.cpp sorter.cpp heap.cpp bubblesort.cpp mergesort.cpp heapsort.cpp stdsort.cpp algo.cpp kruskals.cpp prims.cpp datastrategy.cpp stdqueue.cpp
HEADERS := graph.h list.h utils.h set.h queue.h unordered.h sorter.h heap.h sortstrategy.h mergesort.h heapsort.h bubblesort.h stdsort.h algo.h algostrategy.h kruskals.h prims.h datastrategy.h stdqueue.h
OBJECTS := $(SOURCES:%.cpp=%.o)

# Dependencies
DEPEND := $(OBJECTS:%.o=%.d)
-include $(DEPEND)

# For compiling different versions
all: $(TARGETS)
dbg := n

ifeq ($(dbg), y)
	CFLAGS += $(DBGFLAGS)
else
	CFLAGS += $(OPTFLAGS)
endif

ifeq ($(edgecount), y)
   CFLAGS += $(EDGEFLAGS)
endif

# Actual compile command
all : $(OBJECTS)
	$(CC) -o $(EXE) $(LDFLAGS) $(CFLAGS) $(OBJECTS)

# Rule for compiling object files
.cpp.o:
	$(CC) $(CFLAGS) -c $< -o $@

# NOTE: We'll cover dependencies at a later date

# Removing object files
.PHONY : clean
clean :
	$(RM) $(OBJECTS)
